package cn.myjerry.thread.status;

import java.util.Date;

/**
 * 线程的停止
 * @author Jerry
 *
 */

public class StopDemo01 {
	public static void main(String[] args) {
		Study s = new Study();
		new Thread(s).start();
		
		for(int i=0;i<10;i++) {
			if(i > 5) {
				s.stop();
			}
			System.out.println("main.... --> " + i + " --> " + new Date().getTime());
		}
	}
}
class Study implements Runnable {
	// 定义标示
	Boolean flsg = true;
	
	@Override
	public void run() {
		// 使用标示
		while(flsg) {
			System.out.println("运行中..." + new Date().getTime());
		}
	}

	// 终止线程
	public void stop() {
		this.flsg = false;
	}
}